home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / s3bas11.zip / S3VIDEO.BAS < prev    next >
BASIC Source File  |  1993-04-20  |  6KB  |  226 lines

  1. ' S3 VGA video determination demo
  2. '
  3. 'Copyright April 2, 1992:  George Spafford
  4. '
  5. 'Use int 10H, function 1AH and subfunction 00H
  6. '
  7. '----------------------------------------------
  8.  
  9.  
  10. TYPE RegType
  11.      AX    AS INTEGER
  12.      bx    AS INTEGER
  13.      cx    AS INTEGER
  14.      dx    AS INTEGER
  15.      bp    AS INTEGER
  16.      si    AS INTEGER
  17.      DI    AS INTEGER
  18.      flags AS INTEGER
  19. END TYPE
  20.  
  21. TYPE RegTypeX
  22.      AX    AS INTEGER
  23.      bx    AS INTEGER
  24.      cx    AS INTEGER
  25.      dx    AS INTEGER
  26.      bp    AS INTEGER
  27.      si    AS INTEGER
  28.      DI    AS INTEGER
  29.      flags AS INTEGER
  30.      ds    AS INTEGER
  31.      ES    AS INTEGER
  32. END TYPE
  33.  
  34. DECLARE SUB INTERRUPT (intnum AS INTEGER, inreg AS RegType, outreg AS RegType)
  35. DECLARE SUB INTERRUPTX (intnum AS INTEGER, inregX AS RegTypeX, outregX AS RegTypeX)
  36. DECLARE FUNCTION MakeWord& (Num AS INTEGER)
  37.  
  38. DIM InRegs AS RegType
  39. DIM OutRegs AS RegType
  40. DIM InRegsX AS RegTypeX
  41. DIM OutRegsX AS RegTypeX
  42.  
  43. DEFINT A-Z
  44.  
  45. CLS
  46. PRINT "S3 Software VGA Identification Demo."
  47. PRINT
  48.  
  49. intnum = &H10
  50. InRegs.AX = &H1A * 256          'load AH (primary)
  51.  
  52. 'the previous load cleared AL but oh well, this is a
  53. 'demo.  A value * 256 loads AH but clears AL.  To
  54. 'load AH without clearing AL you would do something
  55. 'like InRegs.AX=InRegs.AX OR (&H1A * 256)  The OR
  56. 'operator allows AH to be loaded independently.
  57.  
  58. 'We are calling interrupt 10H with function 1AH with
  59. 'subfunction 0.  That's why we really did  not need
  60. 'to load AL since it was already cleared, but I wanted
  61. 'you to see how to load AH and AL independently.
  62.  
  63. CALL INTERRUPT(intnum, InRegs, OutRegs)
  64.  
  65. 'Now, this function must return &H1A in the AL register.
  66. 'If it does not, then a VGA card is not in the PC and we
  67. 'will end the program.  The MakeWord&() function takes an
  68. 'a integer value an turns it into a long integer just
  69. 'in case the integer has its sign bit used.
  70.  
  71. AL = MakeWord&(OutRegs.AX) AND &HFF
  72. IF AL <> &H1A THEN
  73.    PRINT "This test requires VGA"
  74.    END
  75. END IF
  76.  
  77. 'Now, BL contains the information for the currently
  78. 'active video adapter in the PC.  Since most of us
  79. 'only have one, it will probably be the only one
  80. 'identified when you run the sample program.
  81. 'Note, we once again make the register a long value
  82. 'before we pull out the 8 bit register we want.
  83.  
  84. PRINT "Active Video Adapter:"
  85. PRINT "     ";
  86. BL = MakeWord&(OutRegs.bx) AND &HFF
  87. SELECT CASE BL
  88.        CASE &HFF
  89.             PRINT "Unknown video card"
  90.        CASE &H0
  91.             PRINT "No adapter located"
  92.        CASE &H1
  93.             PRINT "MDA adapter with monochrome monitor"
  94.        CASE &H2
  95.             PRINT "CGA adapter with color monitor"
  96.        CASE &H4
  97.             PRINT "EGA adapter with EGA or multisynch monitor"
  98.        CASE &H5
  99.             PRINT "EGA adapter with a monochrome monitor"
  100.        CASE &H7
  101.             PRINT "VGA adapter with an analog monochrome monitor"
  102.        CASE &H8
  103.             PRINT "VGA adapter with an analog color monitor"
  104. END SELECT
  105.  
  106. 'In the case of dual video adapter systems, BH contains
  107. 'information for the inactive video adapter.
  108.  
  109. PRINT
  110. PRINT "Inactive Video Adapter:"
  111. PRINT "     ";
  112. BH = MakeWord&(OutRegs.bx) \ 256
  113. SELECT CASE BH
  114.        CASE &HFF
  115.             PRINT "Unknown video card"
  116.        CASE &H0
  117.             PRINT "No adapter located"
  118.        CASE &H1
  119.             PRINT "MDA adapter with monochrome monitor"
  120.        CASE &H2
  121.             PRINT "CGA adapter with color monitor"
  122.        CASE &H4
  123.             PRINT "EGA adapter with EGA or multisynch monitor"
  124.        CASE &H5
  125.             PRINT "EGA adapter with a monochrome monitor"
  126.        CASE &H7
  127.             PRINT "VGA adapter with an analog monochrome monitor"
  128.        CASE &H8
  129.             PRINT "VGA adapter with an analog color monitor"
  130. END SELECT
  131.  
  132.  
  133. 'Now, let us hunt for the dreaded VESA extensions.
  134. 'By using interrupt 10H with function 4FH and subfunction
  135. '00H, we can look for a VESA compliant SVGA. 
  136.  
  137. intnum = &H10
  138. InRegsX.AX = &H0                         'load AL FIRST!!
  139. InRegsX.AX = InRegsX.AX OR (&H4F * 256)   'load AH (primary)
  140.  
  141. CALL INTERRUPTX(intnum, InRegsX, OutRegsX)
  142.  
  143. 'For a detailed look at splitting high and low bytes,
  144. 'look at the S3DATE.BAS example program.
  145.  
  146. AH = MakeWord&(OutRegsX.AX) \ 256
  147. AL = MakeWord&(OutRegsX.AX) AND &HFF
  148.  
  149. 'if AL contains 4fH and AH contains 0H then the
  150. 'system is VESA compliant. 
  151.  
  152. IF AL = &H4F AND AH = &H0 THEN
  153.  
  154.    'The DEF SEG line changes the current memory
  155.    'segment to that which is specified in the ES
  156.    'segment register.
  157.  
  158.    DEF SEG = (OutRegsX.ES)
  159.    Vesa$ = ""
  160.  
  161.    'Next, we read starting at the offset specified
  162.    'in DI for the VESA signature.  In order to
  163.    'guarantee that the system is indeed a VESA
  164.    'system and the AL and AH aren't incidentally
  165.    'correct, DI to DI + 3 have the word "VESA"
  166.    'distributed through each offset.  In other
  167.    'words, the offset DI has "V", DI + 1 has "E" and
  168.    'so forth.
  169.  
  170.    FOR a = 0 TO 3
  171.        B = PEEK(OutRegsX.DI + a)
  172.        Vesa$ = Vesa$ + CHR$(B)
  173.    NEXT a
  174.    IF Vesa$ = "VESA" THEN
  175.       PRINT
  176.       PRINT "VESA extensions confirmed"
  177.       PRINT
  178.      'Next, the High Level Version Number can be pulled
  179.      'out at offset DI + 4.
  180.      HLV = PEEK(OutRegsX.DI + &H4)
  181.      'The Low Level Version Number can be pulled out
  182.      'at the offset DI + 5.
  183.      LLV = PEEK(OutRegsX.DI + &H5)
  184.      'DEF SEG by itself will return the Segment address
  185.      'to the default segment.
  186.      DEF SEG
  187.      PRINT "Vesa Signature..............:  "; Vesa$
  188.      PRINT "High Level Version Number...:  "; HLV
  189.      PRINT "Low Level Version Number....:  "; LLV
  190.    END IF
  191. END IF
  192.  
  193. IF Vesa$ <> "VESA" THEN
  194.    PRINT
  195.    PRINT "Not VESA Compliant"
  196.    PRINT
  197. END IF
  198.  
  199.  
  200. 'When you performed the function call, if AH contains
  201. '&H1, then some type of error occurred.
  202.  
  203. IF AL = &H4F AND AH = &H1 THEN
  204.    PRINT : PRINT
  205.    PRINT "Error executing VESA identification."
  206. END IF
  207.  
  208. PRINT : PRINT
  209.  
  210. 'Well, another thrilling example has come to a close.
  211. 'I do not know about you, but I am so excited I could
  212. 'fall over.
  213.  
  214. END
  215.  
  216.  
  217. DEFSNG A-Z
  218. FUNCTION MakeWord& (Num AS INTEGER)
  219.     IF Num < 0 THEN
  220.        MakeWord& = 65536 + Num
  221.     ELSE
  222.        MakeWord& = Num
  223.     END IF
  224. END FUNCTION
  225.  
  226.